home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / calc.bas < prev    next >
BASIC Source File  |  1985-09-27  |  1KB  |  29 lines

  1. 10 REM calc - calculate peeks and pokes
  2. 20 DEFINT A-Z
  3. 30 CLS
  4. 40 PRINT "Enter an eight digit bit pattern, using"
  5. 50 PRINT "0 for non-significant bits and any"
  6. 60 PRINT "other character for significant bits."
  7. 70 PRINT "To return to the menu, press return"
  8. 80 PRINT "with no input."
  9. 90 PRINT
  10. 100 INPUT "Bit pattern (8 digits)";BIT$
  11. 110 IF BIT$="" THEN RUN"MENU":END
  12. 120 IF LEN(BIT$)<>8 THEN PRINT "Bit pattern must be 8 characters long":BEEP:GOTO 100
  13. 130 NUM=0:ZCOUNT=0
  14. 140 PRINT "Binary: ";
  15. 150 FOR I=1 TO 8
  16. 160 X$=MID$(BIT$,I,1)
  17. 170 IF X$="0" THEN ZCOUNT=ZCOUNT+1:PRINT X$;:GOTO 190
  18. 180 PRINT "1";:NUM=2^(8-I)+NUM:ZCOUNT=0
  19. 190 NEXT I
  20. 200 IF NUM=0 THEN PRINT:PRINT "No bits set":BEEP:GOTO 100
  21. 210 PRINT "    Hex: " HEX$(NUM)  "    Ascii:" NUM;
  22. 220 IF NUM>=32 THEN PRINT "    Character: " CHR$(NUM) ELSE PRINT
  23. 230 PRINT "Isolate: ( X AND" NUM ") /" 2^ZCOUNT
  24. 240 PRINT "Clear  : ( X AND" 255-NUM ")"
  25. 250 PRINT "Set    : ( X OR" NUM ")"
  26. 260 PRINT "Toggle : ( X XOR" NUM ")"
  27. 270 PRINT
  28. 280 GOTO 100
  29.